import java.io.IOException;
import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;


public class SteamUser
{
	private String steamID;
	private String avatar;
	private String handle;
	private String profileURL;
	private String realName;
	private String countryCode;
	private String lastLogoff;
	private int status;
	
	public SteamUser()
	{
		
	};
	
	public void setSteamID(String userName) throws Exception
	{
		String data = null;
		String profileURL = "http://steamcommunity.com/id/"+userName+"/?xml=1";
        
		data = SteamXMLParsers.returnXML(profileURL);
		
        Document userDoc = SteamXMLParsers.parseXML(data);

		NodeList profileNodes = userDoc.getElementsByTagName("profile");
		
		for(int i=0;i<profileNodes.getLength();i++)
		{
			Element element = (Element)profileNodes.item(i);
			
			NodeList sIDElement = element.getElementsByTagName("steamID64"); 
			Element line = (Element) sIDElement.item(0);
			this.steamID = SteamXMLParsers.getCharacterDataFromElement(line);
		}

	}

	public String getSteamID()
	{
		return steamID;
	}
	
	public void setAvatar(String avatarURL)
	{
		avatar = avatarURL;
	}
	
	public String getAvatar()
	{
		return avatar;
	}
	
	public void setHandle(String handleName)
	{
		handle=handleName;
	}
	
	public String getHandle()
	{
		return handle;
	}
	
	public void setStatus(int userStatus)
	{
		status=userStatus;
	}
	
	public int getStatus()
	{
		return status;
	}
}

